<?php 
/* Template Name: Especie */

$post = $wp_query->post;
get_header();
?>

<style type="text/css">
.cont-logo-parque-zoo {margin: auto; display: table;}
.cont-outra-info {width: 400px; height: auto; margin: auto; display: table;}
.gmap3 {margin: 20px auto; border: 1px dashed #C0C0C0; width: 195px; height: 125px;}

#basic-accordian{width:610px;left:50%;top:50%;margin:auto;z-index:2;}
.accordion_headings{padding:18px;background:#99CC00;color:#FFFFFF;border:1px solid #FFF;cursor:pointer;font-size:22px;height:60px;}
.accordion_headings:hover{background:#00CCFF;}
.accordion_child{padding:15px;background:#EEE;}
.header_highlight{background:#00CCFF;height:60px;}

</style>

<script type="text/javascript">
eval((function(){a=" {3document5ByIdOgvv=8E!&&E!K32}o=E;E;v=parseInt(2E=o;3vdheight=vHpx}Oofvgvv=v/d.h;dDv;dfilterKalpha(D+v*100H)Obz>0z#-1:z-v90E;%eE;z<x(x-z)#+1:v+z9x%Accordians,fl=5sByTagName(diva=[]d=S;QQ,Q)=={a.push}}xL((hc=h0,hc6==hcMc+;c;coverflowKhidden;c.h=g(cc.s=(s=8)?7:s;h.f=f;h.c=a;h.match4fHH))x=h}hC=(Rj=0;j<F.c;j++n=F.c[j];n=n0,ndMn6nMn+;s=dJt4sH)Rp=0;p<s;p++s[p]=KGsJce(p,1d=s.join( break}}clearn.tQ==FPg(n,0@ed+K GP@b}}}}})(S)}x!LxC()}}",b=49;while(b>=0)a=a.replace(new RegExp("#%2345689@CDEFGHJKLMOPQRS".charAt(b),"g"),("\\\042\044.style.displayfunctionInterval(.className.length.indexOf(-)(d)if(-content).id){.style.=none{d=;z=g;x=d.h;(d,;for(i=0;i<l;i++);}else{('+n+')',9)}.substr(=blockv=Math.round(/d.sv=(v<1)?zcleard.t)}} d.offsetHeightreturn (new RegExp(.getElement+-header=undefined;ofv)gn.t=set'.onclickopacity=dthis+d.f+.spli==null=(} n=dfor(l[i]".split(""))[b--]);return a})())
</script>

<div class="cont-topo">		
	<div class="bar-page" style="border-bottom: 2px #efefef solid;"><?php conteudo_barra_page ('Link direto:&nbsp;'); ?></div>
	<div class="vertical_space_20"></div>		
	<div class="bar-page"><?php titulo_barra_page ('Especies de Aves', get_the_title()); ?></div>
	<div class="vertical_space_20"></div>
</div><!-- Fim div conteiner-topo -->

<div class="vertical_space_20"></div>

<div class="cont-miolo">
	<?php 		
	include_once TEMPLATEPATH.'/av-define.php';
	include_once PDO.'/NextGenPDO.class.php';
	$ng = new NextGenPDO ();
	$linha = $ng->galeria_id_by_author($post->post_author);		// gid, name, previewpic, author - gallery
	$galeria_picture_tudo = $ng->galeria_get_picture_source();	// filename, path, gid, author, name - gallery_pictures
	?>

	<div class="cont-logo-parque-zoo">
		<?php
		if (have_posts()) : 
			while (have_posts()) : the_post();
				the_thumb(large);       		
   			endwhile; 
			endif; 
			?>
 	</div>
	<div class="clr"></div>	
	<div class="vertical_space_30"></div>
	
	<div style="width: 620px; float: right; font-size: 24px;">Fotos de criadores</div>

	<?php
	// ================================================================================================================================	
	// Verifica se há galeria de fotos de aves do criador, se sim mostra, do contrário oculta está área	
	// ================================================================================================================================
	if ( $linha != 0 ) { 
    	foreach ($linha as $key => $value) { 
    		$no_space_park_name = str_replace(' ', '', $value['name']);
			$no_space_title = retira_acentos(strtolower(str_replace(' ', '', get_the_title())));					
    		if ( strcmp($no_space_park_name, 'parques-zoos-'.$no_space_title) == 0  && $value['previewpic'] != 0 ) { ?>
		    	<div class="cont-carrossel"> 
			    	<script type="text/javascript">
						$(document).ready(function() {
							$('.slider1').bxSlider( {
							    slideWidth: 130,
							    minSlides: 4,
							    maxSlides: 4,
							    slideMargin: 10,
							    controls: true,
							    pager: false
						    });
						});
					</script>
					<style type="text/css">
					.bx-wrapper {
					    margin: 0 auto 10px;
					    padding: 0;
					    position: relative;
					}
					</style>
					<div style="width: 610px; float: right; font-size: 24px;">Fotos</div>
					<div class="vertical_space_40"></div>
					
					<div class="slider1"> 
						<?php								  	
					  	//Quantidade de fotos da galeria
					  	$aux_qtde_pictures = 0; 
				  		foreach ($galeria_picture_tudo as $key => $value) {
				  			if ( strcmp($no_space_park_name, 'parques-zoos-'.$no_space_title) == 0) {
				  				$aux_qtde_pictures = $aux_qtde_pictures + 1;
				  				$fotos [] = $value;
				  			}		  			
				  		}
				  		$aux_grade = 0;
				  		foreach ($fotos as $key => $value) {
				  			$aux_grade = $aux_grade + 1;
				  			if ( eh_par($aux_grade) == 0 ) { ?>
				  				<div class="slide">
							  		<a href="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>">
										<img src="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>" width="198px" height="96px" style="margin-bottom: 10px;" />
									</a>
				  			<?php
				  			} else { ?>
					  				<a href="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>">
										<img src="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>" width="198px" height="96px" />
									</a>
								</div><!-- Fim div slide-->
				  			<?php
				  			}
				  			if ( eh_par($aux_qtde_pictures) == 0 && ($aux_qtde_pictures - 1 == $aux_grade) ) {
				  				break;
				  			}								  								  			
				  		}
						?>
					</div><!-- Fim div slide1-->
				</div>	
				<?php
			}	
    	}
    }
	// ================================================================================================================================
	?>
	<div class="vertical_space_50"></div>

	<div id="basic-accordian" >		
		
		<div id="test-header" class="accordion_headings header_highlight" >DESCRIÇÃO GERAL</div>
		<div id="test-content">
			<div class="accordion_child"><?php echo get_post_meta($post->ID, 'avpt_especie_descricao_geral', true); ?></div>
		</div>
		<div class="vertical_space_10"></div>
		
		<div id="test1-header" class="accordion_headings" >CRIAÇÃO / MANUTENÇÃO</div>
		<div id="test1-content">
			<div class="accordion_child"><?php echo get_post_meta($post->ID, 'avpt_especie_criacao_manutencao', true); ?></div>
		</div>
		<div class="vertical_space_10"></div>
		
		<div id="test2-header" class="accordion_headings" >CRIAÇÃO A MÃO / DOMESTICAÇÃO</div>
		<div id="test2-content">		  
			<div class="accordion_child"><?php echo get_post_meta($post->ID, 'avpt_especie_criacao_mao_domesticacao', true); ?></div>
		</div>
		<div class="vertical_space_10"></div>
		
		<div id="test3-header" class="accordion_headings" >NUTRIÇÃO E SAUDE</div>
		<div id="test3-content">		  
			<div class="accordion_child"><?php echo get_post_meta($post->ID, 'avpt_especie_nutricao_saude', true); ?></div>
		</div>
		<div class="vertical_space_10"></div>
		
		<div id="test4-header" class="accordion_headings" >CARACTERÍSTICAS</div>
		<div id="test4-content">		  
			<div class="accordion_child"><?php echo get_post_meta($post->ID, 'avpt_especie_caracteristicas', true); ?></div>
		</div>
		<div class="vertical_space_10"></div>
		
		<div id="test5-header" class="accordion_headings" >CURIOSIDADES</div>
		<div id="test5-content">		  
			<div class="accordion_child"><?php echo get_post_meta($post->ID, 'avpt_especie_curiosidades', true); ?></div>
		</div>
		<div class="vertical_space_10"></div>		  
		
		<div id="test6-header" class="accordion_headings" >BIOGRAFIA / AGRADECIMENTOS</div>
		<div id="test6-content">		  
			<div class="accordion_child">
				<?php echo get_post_meta($post->ID, 'avpt_especie_biografia', true); ?><br /><br />
				<?php echo get_post_meta($post->ID, 'avpt_especie_agradecimento', true); ?>
			</div>
		</div>
	</div><!--End of accordion parent-->
	<div class="vertical_space_30"></div>
	
	<div class="cont-outra-info">
		<br /></br>
		<div style="width: 610px; float: right; font-size: 24px;">Outras Informações</div>
		<br /></br><br />
		<span class="azul18">Título</span>
		<br /><br />
		<span class"preto16"><?php echo get_post_meta($post->ID, 'avpt_parques_zoos_outras_info', true); ?></span>
 	</div>
	<div class="clr"></div>	

	<div class="vertical_space_30"></div>
</div><!-- Fim div cont-miolo -->


<div class="cont-direita">

	<?php
	// ================================================================================================================================
	// Bloco contatos: Mostra os seguintes itens do criador: Email, telemóvel e página web do criador 
	// ================================================================================================================================		
	?>
	<div class="cont-contatos" style="border: 1px solid #efefef">
		<div style="margin-left: 10px;"><span class="preto24">Classificação</span></div>
		<div class="vertical_space_15"></div>
		<ul style="list-style-type: none; padding: 0; margin: 0 0 0 10px;">
			<li>
				<br />
				<div style="float: left;"><img alt="" src="<?php echo bloginfo('template_directory')?>/images/icon/info.png" width="20" height="20" /></div>
				<div style="float: left; width:90%;"><span class"preto16">&nbsp;Nome comum</span></div>
				<br />
				<span class="azul16">&nbsp;<?php echo get_post_meta($post->ID, 'avpt_especie_nome_comum', true); ?></a></span>
				<br /><br />
			</li>			
			<?php 
			if ( get_post_meta($post->ID, 'avpt_especie_nome_cientifico', true) ) { ?>
				<li>
					<div style="float: left; width:90%;"><span class"preto16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Nome científico</span></div>
					<span class="azul16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo get_post_meta($post->ID, 'avpt_especie_nome_cientifico', true);?></span>
			    <br /><br />
			    </li>			    			   
			<?php 	
			}			 
			if ( get_post_meta($post->ID, 'avpt_especie_outros_nomes', true) ) { 
				$outros_nomes = get_post_meta($post->ID, 'avpt_especie_outros_nomes', true);
				$outro_nome = explode(';', $outros_nomes);
				$size = sizeof($outro_nome);
				?>
				<li>
					<div style="float: left; width:90%;"><span class"preto16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Outros nomes</span></div>					
					<?php
					for ($i = 0; $i <= $size; $i++) { 
						if ($i==0) { ?>
							<span class="azul16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo ($outro_nome[$i]).'<br />';?></span>						
						<?php						
						} else { ?>
							<span class="azul16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo ($outro_nome[$i]).'<br />';?></span>
						<?php
						}
				    }
				    ?>
			    </li>			   
			<?php 	
			}
			if ( get_post_meta($post->ID, 'avpt_especie_ordem', true) ) { ?>
				<li>
					<div style="float: left; width:90%;"><span class"preto16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ordem</span></div>
					<span class="azul16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo get_post_meta($post->ID, 'avpt_especie_ordem', true);?></span>
			    <br /><br />
			    </li>			    			   
			<?php 	
			}
			if ( get_post_meta($post->ID, 'avpt_especie_familia', true) ) { ?>
				<li>
					<div style="float: left; width:90%;"><span class"preto16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Família</span></div>
					<span class="azul16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo get_post_meta($post->ID, 'avpt_especie_familia', true);?></span>
			    <br /><br />
			    </li>			    			   
			<?php 	
			}
			if ( get_post_meta($post->ID, 'avpt_especie_genero', true) ) { ?>
				<li>
					<div style="float: left; width:90%;"><span class"preto16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gênero</span></div>
					<span class="azul16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo get_post_meta($post->ID, 'avpt_especie_genero', true);?></span>
			    <br /><br />
			    </li>			    			   
			<?php 	
			}
			if ( get_post_meta($post->ID, 'avpt_especie_cities', true) ) { ?>
				<li>
					<div style="float: left; width:90%;"><span class"preto16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CITIES</span></div>
					<span class="azul16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo get_post_meta($post->ID, 'avpt_especie_cities', true);?></span>
			    <br /><br />
			    </li>			    			   
			<?php 	
			}
			if ( get_post_meta($post->ID, 'avpt_especie_origem', true) ) { ?>
				<li>
					<div style="float: left; width:90%;"><span class"preto16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Origem</span></div>
					<span class="azul16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo get_post_meta($post->ID, 'avpt_especie_familia', true);?></span>
			    <br /><br />
			    </li>			    			   
			<?php 	
			}	
			if ( get_post_meta($post->ID, 'avpt_especie_esperanca_vida', true) ) { ?>
				<li>
					<div style="float: left; width:90%;"><span class"preto16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Esperança de vida</span></div>
					<span class="azul16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo get_post_meta($post->ID, 'avpt_especie_esperanca_vida', true);?></span>
			    <br /><br />
			    </li>			    			   
			<?php 	
			}
			if ( get_post_meta($post->ID, 'avpt_especie_tamanho', true) ) { ?>
				<li>
					<div style="float: left; width:90%;"><span class"preto16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tamanho</span></div>
					<span class="azul16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo get_post_meta($post->ID, 'avpt_especie_tamanho', true);?></span>
			    <br /><br />
			    </li>			    			   
			<?php 	
			}					
			if ( get_post_meta($post->ID, 'avpt_especie_subespecie_raca', true) ) { 
				$outros_nomes = get_post_meta($post->ID, 'avpt_especie_subespecie_raca', true);
				$outro_nome = explode(';', $outros_nomes);
				$size = sizeof($outro_nome);
				?>
				<li style="border-bottom: 2px solid #efefef; width:250px;"> &nbsp; </li>
				<li>
					<br />
					<div style="float: left;"><img alt="" src="<?php echo bloginfo('template_directory')?>/images/icon/down.png" width="20" height="20" /></div>
					<div style="float: left; width:90%;"><span class"preto16">&nbsp;Subespécies / Raças</span></div>
					<br />
					<?php
					for ($i = 0; $i <= $size; $i++) { 
						if ($i==0) { ?>
							<span class="azul16">&nbsp;<?php echo ($outro_nome[$i]).'<br />';?></span>						
						<?php						
						} else { ?>
							<span class="azul16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo ($outro_nome[$i]).'<br />';?></span>
						<?php
						}
				    }
				    ?>
			    </li>			   
			<?php
			}
			if ( get_post_meta($post->ID, 'avpt_especie_referencia_web', true) ) { 
				$outros_nomes = get_post_meta($post->ID, 'avpt_especie_referencia_web', true);
				$outro_nome = explode(';', $outros_nomes);
				$size = sizeof($outro_nome);
				?>
				<li style="border-bottom: 2px solid #efefef; width:250px;"> &nbsp; </li>
				<li>
					<br />
					<div style="float: left;"><img alt="" src="<?php echo bloginfo('template_directory')?>/images/icon/laptop.png" width="20" height="20" /></div>
					<div style="float: left; width:90%;"><span class"preto16">&nbsp;Referências na web</span></div>
					<br />
					<?php
					for ($i = 0; $i <= $size; $i++) { 
						if ($i==0) { ?>
							<span class="azul16">&nbsp;<?php echo ($outro_nome[$i]).'<br />';?></span>						
						<?php						
						} else { ?>
							<span class="azul16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo ($outro_nome[$i]).'<br />';?></span>
						<?php
						}
				    }
				    ?>
			    </li>			   
			<?php 	
			}
			?>
		</ul>
	</div>
	<div class="clr"></div>
	<?php
	// ================================================================================================================================

	// ================================================================================================================================		
	// Bloco contatos 2: Mostra outros itens do criador: localidade, modalidade, federação, identificação e licença 
	// ================================================================================================================================		
	?>
	<div class="cont-criador">		
		<div class="vertical_space_15"></div>
		<?php
		load_bloco_criador_sobre ( get_user_meta($user_info->ID, 'concelho', true), 
			get_user_meta($user_info->ID, 'modalidade', true), 
			get_user_meta($user_info->ID, 'clube', true), 
			get_user_meta($user_info->ID, 'clube2', true), 
			get_user_meta($user_info->ID, 'clube3', true), 
			get_user_meta($user_info->ID, 'stam', true), 
			get_user_meta($user_info->ID, 'licenca', true) ); ?>
	</div><!-- Fim div cont-criador -->
	<div class="clr"></div>
	<div class="vertical_space_40"></div>
	<?php
	// ================================================================================================================================

// ================================================================================================================================		
	// Verifica se vieram dados do formulário de contato, se sim dispara email
	// ================================================================================================================================		  
	if (isset($_POST["from_form"])) {			
		$from_form = $_POST["from_form"]; 			
		if ( $from_form == 1 ) {
			if (isset($_POST["message"]))    {$internauta_mensagem = $_POST["message"];}
			if (isset($_POST["nome"]))       {$internauta_nome = $_POST["nome"];}
			if (isset($_POST["telefone"]))   {$internauta_telefone = $_POST["telefone"];}
			if (isset($_POST["email"]))      {$internauta_email = $_POST["email"];}
			if (isset($_POST["email_copy"])) {$internauta_email_copia = $_POST["email_copy"];}
			if (isset($_POST["email_dest"])) {$internauta_email_destinatario = $_POST["email_dest"];}
			//Prepara e envia email
			$email_destinatario  = $internauta_email_destinatario;
			$email_assunto       = '[AVES PT] Contato internauta';
			$internauta_mensagem = $internauta_nome. ' Recomenda: ' .url_atual(). '<br /><br />'. $internauta_mensagem;
			if ( $internauta_email_copia != 1 ) {
				$internauta_email_copia = 0;
				envia_email ( $internauta_email, $email_destinatario, 
					$internauta_nome, $internauta_telefone, $internauta_mensagem, $email_assunto, $internauta_email_copia);
			} else {
				envia_email ( $internauta_email, $email_destinatario, 
					$internauta_nome, $internauta_telefone, $internauta_mensagem, $email_assunto, $internauta_email_copia);
			}
		}			
	}
	// ================================================================================================================================

	// ================================================================================================================================		
	// Bloco Formulário para contactar criador e indicar a página para outros internautas
	// ================================================================================================================================
	load_form_email();
	?>
	<div class="vertical_space_20"></div>
	<div class="clr"></div>
	<div class="vertical_space_50"></div>
	<?php
	// ================================================================================================================================
	?>

</div><!-- Fim div cont-direita -->


<div class="cont-direitos" style="border-top: 2px #efefef solid;">
	<?php direito_barra_page ("Página de detalhes do ", get_the_title()); ?>
</div>

</div><!-- Fim div corpo -->
<div class="vertical_space_20"></div>

<div class="cont-miolo-pub"><?php add_google_pub_bloco_2x468x60 (); ?></div>
<div class="vertical_space_20"></div>

</div><!-- Fim div tudo -->

<?php get_footer(); ?>

</body>

</html>